//
//  VideoViewController.m
//  Daily Watch
//
//  Created by 安静的美男子 on 14-10-15.
//  Copyright (c) 2014年 安静的美男子. All rights reserved.
//

#import "VideoViewController.h"

@interface VideoViewController ()

@end

@implementation VideoViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        self.title = @"精彩视频";
        self.dataSource = [NSMutableArray array];
        self.mainView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 568)];
        _mainView.backgroundColor = [UIColor clearColor];
        self.data = [[analysis alloc]init];
        
        [self.view addSubview:_mainView];
        
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self getData];
    [self CreatButton];
//    [self creatScroll];
    // Do any additional setup after loading the view.
}
#pragma mark -
#pragma mark 创建滚动视图
-(void)getData
{
    analysis *data = [[analysis alloc]init];
    [data Analysis];
    [data sendBlock:^(id result) {
        _dataSource = result;
        NSLog(@"%@", _dataSource);
        [self creatScroll];
    }];

}
-(void)creatScroll
{
    self.ScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 368, 320, 150)];
    _ScrollView.backgroundColor = [UIColor purpleColor];
    _ScrollView.contentSize = CGSizeMake(320 /2 *_dataSource.count, 150);
    
    for (int i = 0; i< _dataSource.count; i++) {
        UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(5 + i*105, 20, 100, 100)];
        button.backgroundColor = [UIColor whiteColor];
        [_ScrollView addSubview:button];
       
    }
    [_mainView addSubview:_ScrollView];
    
}
-(void)CreatButton
{
    
    
    [_todayButton addTarget:self action:@selector(TodayButtonAction) forControlEvents:UIControlEventTouchUpInside];
    [_NewsButton addTarget:self action:@selector(NewsButtonAction) forControlEvents:UIControlEventTouchUpInside];
    [_brandsButton addTarget:self action:@selector(brandsButtonAction) forControlEvents:UIControlEventTouchUpInside];
//    [_videoButton addTarget:self action:@selector(videoButtonAction) forControlEvents:UIControlEventTouchUpInside];
    [_settingButton addTarget:self action:@selector(settingButtonAction) forControlEvents:UIControlEventTouchUpInside];
    [_emptyButton addTarget:self action:@selector(emptyButtonAction) forControlEvents:UIControlEventTouchUpInside];
}
-(void)TodayButtonAction
{
    TodayViewController *today = [[TodayViewController alloc]init];
    [self.navigationController pushViewController:today animated:YES];
    [today release];
    
}
-(void)NewsButtonAction
{
    NewsViewController *new = [[NewsViewController alloc]init];
    [self.navigationController pushViewController:new animated:YES];
    [new release];
}
-(void)brandsButtonAction
{
    BrandsViewController *bra = [[BrandsViewController alloc]init];
    [self.navigationController pushViewController:bra animated:YES];
    [bra release];
}
//-(void)videoButtonAction
//{
//    VideoViewController *video = [[VideoViewController alloc]init];
//    [self.navigationController pushViewController:video animated:YES];
//    [video release];
//}
-(void)emptyButtonAction
{
    AboutUsViewController *about = [[AboutUsViewController alloc]init];
    [self.navigationController pushViewController:about animated:YES];
    [about release];
}
-(void)settingButtonAction
{
    settingViewController *setting = [[settingViewController alloc]init];
    [self.navigationController pushViewController:setting animated:YES];
    [setting release];
}
-(void)rightNavBtn
{
    [super rightNavBtn];
    [self.view sendSubviewToBack:_mainView];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
